home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / T U R B O Language / Turbo C Tools v6.0 / INCLUDE / BWINDOW.H < prev    next >
Text File  |  1989-03-31  |  35KB  |  1,025 lines

  1. /**
  2. *
  3. *  BWINDOW.H    Header file for Turbo C TOOLS Window Functions
  4. *
  5. *  Version    6.00 (C)Copyright Blaise Computing Inc.  1986,1987,1989
  6. *
  7. **/
  8.  
  9.  
  10. #ifndef DEF_BWINDOW        /* Prevent second reading of        */
  11. #define DEF_BWINDOW  1        /* these definitions.            */
  12.  
  13. #include <bscreens.h>        /* Turbo C TOOLS Screen functions.  */
  14. #include <bkeybrd.h>        /* Turbo C TOOLS Keyboard functions.*/
  15.  
  16. #define WN_EXT_ERROR 1        /* 1 if wnerror() is external, 0 if */
  17.                 /* it's a macro.                    */
  18.  
  19.  
  20.  
  21. /********************************************************************/
  22. /* Definitions of data types.                        */
  23. /********************************************************************/
  24.  
  25. typedef struct            /* LOC structure:            */
  26. {                /* row and column relative to a     */
  27.     int row,col;        /* rectangular region.            */
  28. } LOC;
  29.  
  30.  
  31. typedef struct            /* REGION structure:            */
  32. {                /*   rectangular region on a        */
  33.                 /*   screen.                */
  34.     LOC ul;            /* Upper left  corner.            */
  35.     LOC lr;            /* Lower right corner.            */
  36. } REGION;
  37.  
  38.  
  39. typedef struct            /* CELL structure:            */
  40. {                /* character and attribute byte on  */
  41.     char ch,attr;        /* a PC screen.             */
  42. } CELL;
  43.  
  44.  
  45. typedef struct            /* DIM structure:            */
  46. {                /* height and width of a        */
  47.     int h,w;            /* rectangular region.            */
  48. } DIM;
  49.  
  50.  
  51. typedef struct            /* IMAGE structure:            */
  52. {                /*   a copy of a rectangular        */
  53.                 /*   portion of a screen's data.    */
  54.     DIM  dim;            /* Dimensions of the rectangle.     */
  55.     CELL *pdata;        /* Pointer to array of cells        */
  56.                 /*   containing the data, row        */
  57.                 /*   by row.                */
  58. } IMAGE;
  59.  
  60.  
  61. typedef struct            /* WHERE structure:            */
  62. {                /* device, page, and location        */
  63.                 /* where a window may be shown.     */
  64.                 /*                    */
  65.     int  dev;            /* Device where shown:    COLOR,        */
  66.                 /* MONO, or ABSENT if not shown.    */
  67.                 /*                    */
  68.     int  page;            /* Video page number:  0 to 7        */
  69.                 /*                    */
  70.     LOC  corner;        /* Upper left corner of region        */
  71.                 /* where window data is shown        */
  72.                 /* (does not include border).        */
  73. } WHERE;
  74.  
  75.  
  76. typedef struct bjoint {
  77.     unsigned char  row;     /* Row and column of joint relative */
  78.     unsigned char  col;     /* to upper-left of border.  (0,0). */
  79.     char       jtype;    /* IBM graphic char for joint.        */
  80.     char       _dummy;    /* Structure alignment.         */
  81.     struct bjoint *next;    /* Pointer to next joint in linked  */
  82. } BJOINT;            /* list of joints.            */
  83.  
  84.  
  85. typedef struct {
  86.     int     type;        /* Type of border:            */
  87.                 /*    0 = no border.            */
  88.                 /*   31 = Character "ch" border.    */
  89.                 /*                    */
  90.                 /*      T R B L            */
  91.                 /*      o t o f            */
  92.                 /*      p   t t            */
  93.                 /*                    */
  94.                 /*    1 = S S S S no title.        */
  95.                 /*    2 = S S S D no title.        */
  96.                 /*    3 = D S S S no title.        */
  97.                 /*    4 = D S S D no title.        */
  98.                 /*    5 = S D S S no title.        */
  99.                 /*    6 = S D S D no title.        */
  100.                 /*    7 = D D S S no title.        */
  101.                 /*    8 = D D S D no title.        */
  102.                 /*    9 = S S D S no title.        */
  103.                 /*   10 = S S D D no title.        */
  104.                 /*   11 = D S D S no title.        */
  105.                 /*   12 = D S D D no title.        */
  106.                 /*   13 = S D D S no title.        */
  107.                 /*   14 = S D D D no title.        */
  108.                 /*   15 = D D D S no title.        */
  109.                 /*   16 = D D D D no title.        */
  110.                 /*                    */
  111.                 /* OR the above with:            */
  112.                 /*   0x0020- top-left-title        */
  113.                 /*   0x0040- top-center-title        */
  114.                 /*   0x0080- top-right-title        */
  115.                 /*   0x0100- bottom-left-title        */
  116.                 /*   0x0200- bottom-center-title    */
  117.                 /*   0x0400- bottom-right-title     */
  118.                 /*                    */
  119.                 /* OR the above with:            */
  120.                 /*   0x0800- border has joints.     */
  121.                 /*                    */
  122.     int     attr;        /* Attribute of border.         */
  123.     char    ch;         /* Border character (if type==0).   */
  124.     char    _dummy;        /* Structure alignment.         */
  125.     char   *pttitle;        /* Title on top border.         */
  126.     char   *pbtitle;        /* Title on bottom border.        */
  127.     int     ttattr;        /* Attributes of top title.        */
  128.     int     btattr;        /* Attributes of bottom title.        */
  129.     BJOINT *pjoints;        /* Pointer to linked list of joints.*/
  130. } BORDER;
  131.  
  132.  
  133. typedef enum
  134. {                /* Values for the WN_SENSOR type    */
  135.                 /*   field.                */
  136.     WN_LEFT_ARROW,        /* Left scroll arrow.            */
  137.     WN_RIGHT_ARROW,        /* Right scroll arrow.            */
  138.     WN_UP_ARROW,        /* Up scroll arrow.            */
  139.     WN_DOWN_ARROW,        /* Down scroll arrow.            */
  140.     WN_IN_WINDOW,        /* Inside window's viewport.        */
  141.     WN_ON_BORDER,        /* On window's border.              */
  142.     WN_OUT_WINDOW        /* Outside the window completely.   */
  143. } WN_SENSOR_TYPE;
  144.  
  145. #define WN_LAST_SENSOR    WN_OUT_WINDOW
  146.  
  147.  
  148. #define WN_VIEWPORT 0
  149. #define WN_DATA     1
  150. #define WN_SCREEN   2
  151.  
  152. typedef struct wn_sensor    /* WN_SENSOR structure: linked list */
  153. {                /*   of window sensors.         */
  154.     WN_SENSOR_TYPE    type;    /* The type of sensor this is.        */
  155.     unsigned          relative; /* Whether the sensor is relative   */
  156.                 /*   to the screen, viewport, or    */
  157.                 /*   data area.             */
  158.     REGION          hot;    /* The "hot" region for the sensor. */
  159.     LOC           corner;    /* Displayed corner for the sensor. */
  160.     DIM           size;    /* Displayed size of the sensor.    */
  161.     CELL          *pimage;    /* Sensor's image.                  */
  162.     struct wn_sensor  *pnext;    /* Pointers to the next and        */
  163.     struct wn_sensor  *pprev;    /* previous sensors in the list.    */
  164. } WN_SENSOR;
  165.  
  166.  
  167. typedef enum            /* WN_ACTION:                */
  168. {                /*   values for the WN_EVENT action */
  169.                 /*   field.                */
  170.     WN_NULL,            /* No action.                */
  171.     WN_SCROLL_LEFT,        /* Move left.                */
  172.     WN_SCROLL_RIGHT,        /* Move right.                */
  173.     WN_SCROLL_UP,        /* Move up.                */
  174.     WN_SCROLL_DOWN,        /* Move down.                */
  175.     WN_PAGE_LEFT,        /* Page left.                */
  176.     WN_PAGE_RIGHT,        /* Page right.                */
  177.     WN_PAGE_UP,         /* Page up.                */
  178.     WN_PAGE_DOWN,        /* Page down.                */
  179.     WN_LEFT_EDGE,        /* Go to left edge.            */
  180.     WN_RIGHT_EDGE,        /* Go to right edge.            */
  181.     WN_TOP_EDGE,        /* Go to top edge.            */
  182.     WN_BOTTOM_EDGE,        /* Go to bottom edge.            */
  183.     WN_ABORT,            /* Abort read.                */
  184.     WN_TRANSMIT,        /* Finish read.             */
  185.     WN_INVALID_ACTION        /* Invalid window action.        */
  186. } WN_ACTION;
  187.  
  188.  
  189. #define WN_ABSENT_EVENT 0
  190. #define WN_KB_EVENT    1
  191. #define WN_MOUSE_EVENT    2
  192.  
  193.  
  194. typedef struct            /* MOUSE_EVENT structure:        */
  195. {                /*                    */
  196.     unsigned long   event;    /*   Mouse characteristics to pay   */
  197.     unsigned long   ignore;    /*   attention to & ignore.        */
  198.     unsigned        location;    /*   Location code.            */
  199. } MOUSE_EVENT;
  200.  
  201.  
  202. typedef struct
  203. {                /* WN_EVENT structure:            */
  204.     unsigned         event_type;/* WN_KB_EVENT or WN_MOUSE_EVENT.   */
  205.     union            /* event union:             */
  206.     {                /* The basic data of a keyboard or  */
  207.     KEY_SEQUENCE keystroke; /* mouse event.             */
  208.     MOUSE_EVENT  mouse;    /*                    */
  209.     } event;            /*                    */
  210.     void         *pdata;    /* Event related data.            */
  211.     unsigned         data_size; /* Size of data pointed to by pdata.*/
  212. } WN_EVENT;
  213.  
  214.  
  215. typedef struct wn_event_list           /* WN_EVENT_LIST structure:  */
  216. {                       /*   WN_EVENT, identifying   */
  217.     unsigned          signature;   /*   signature, & pointers   */
  218.     WN_EVENT          win_event;   /*   to next and previous    */
  219.     struct wn_event_list  *pnext;      /*   items in event list.    */
  220.     struct wn_event_list  *pprev;
  221. } WN_EVENT_LIST;
  222.  
  223.  
  224.  
  225. typedef struct            /* BWINDOW structure:            */
  226. {                /*   everything needed to control   */
  227.                 /*   an individual window.        */
  228.                 /*                    */
  229.     unsigned signature;     /* Identifying signature.        */
  230.                 /*                    */
  231.     LOC      cur_loc;        /* Location of window's own         */
  232.                 /* cursor relative to window's      */
  233.                 /* data area.                */
  234.                 /*                    */
  235.     CUR_TYPE cur_type;        /* Cursor type.             */
  236.                 /*                    */
  237.     IMAGE    img;        /* Contents of data area.        */
  238.                 /*                    */
  239.     DIM      view_size;     /* Size of window's viewport.       */
  240.                 /*                    */
  241.     LOC      data_origin;    /* Coordinates of data area which   */
  242.                 /* appear at (0,0) in the viewport. */
  243.                 /*                    */
  244.     WHERE    where_shown;    /* Where window is currently        */
  245.                 /* shown.                */
  246.                 /*                    */
  247.     IMAGE    prev;        /* Previous contents of screen        */
  248.                 /* (before window was shown),        */
  249.                 /* including data under border.     */
  250.                 /*                    */
  251.     WHERE    where_prev;    /* Region occupied by window        */
  252.                 /* (including border).            */
  253.                 /*                    */
  254.     struct bwin_node *pnode;    /* Pointer to window node        */
  255.                 /* among all windows on a video     */
  256.                 /* display page.            */
  257.                 /*                    */
  258.     BORDER   bord;        /* Border description.            */
  259.                 /*                    */
  260.     WN_SENSOR *psensors;    /* Window sensor list.            */
  261.                 /*                    */
  262.     WN_EVENT_LIST *pevent_list; /* Window event list.            */
  263.                 /*                    */
  264.     int      attr;        /* Default attributes for data        */
  265.                 /* area.                */
  266.     unsigned cur_left_marg,    /* Left, right, top, and bottom     */
  267.          cur_right_marg,    /* margins to maintain during        */
  268.          cur_top_marg,    /* cursor "auto-track" feature.     */
  269.          cur_bottom_marg;    /*                    */
  270.  
  271.     struct            /* "options" substructure:          */
  272.     {                /*   items set by user request.     */
  273.                 /*                    */
  274.     unsigned delayed   : 1; /* Output postponed until next        */
  275.                 /* update.                */
  276.                 /*                    */
  277.     unsigned cur_off   : 1; /* Cursor invisible.            */
  278.                 /*                    */
  279.     unsigned removable : 1; /* Removable (hence previous        */
  280.                 /* contents of screen must be        */
  281.                 /* preserved).                */
  282.                 /*                    */
  283.     unsigned hidden    : 1; /* Invisible, yet attached to a     */
  284.                 /* location on a display page.        */
  285.                 /*                    */
  286.     unsigned cur_track : 1; /* Always keep cursor visible in    */
  287.                 /* the viewport.            */
  288.                 /*                    */
  289.     unsigned _dummy    :11; /* Pad to word boundary         */
  290.     } options;
  291.  
  292.     struct            /* "internals" substructure:        */
  293.     {                /*   not directly set by user.        */
  294.                 /*                    */
  295.     unsigned frozen     :1; /* Updates postponed involuntarily. */
  296.                 /*                    */
  297.     unsigned dirty        :1; /* Output request(s) are        */
  298.                 /* awaiting update.            */
  299.                 /*                    */
  300.     unsigned        /* Some portion of data area is     */
  301.         any_data_covered:1; /* covered by another window.        */
  302.                 /*                    */
  303.     unsigned cur_frozen :1; /* Not selected for visible        */
  304.                 /* cursor.                */
  305.                 /*                    */
  306.     unsigned temp_hid   :1; /* Temporarily hidden by        */
  307.                 /* internal operations.         */
  308.                 /*                    */
  309.     unsigned _dummy    :11; /* Pad to word boundary         */
  310.     } internals;
  311. } BWINDOW;
  312.  
  313.  
  314. typedef struct bwin_node    /* WIN_NODE structure:            */
  315. {                /*   node in the linked lists which */
  316.                 /*   govern the hierarchy of        */
  317.                 /*   windows on each display page.  */
  318.                 /*                    */
  319.     unsigned signature;     /* Identifying signature.        */
  320.                 /*                    */
  321.     struct bwin_node *above;    /* Window above this one (or        */
  322.                 /* NIL if this is top window).        */
  323.                 /*                    */
  324.     struct bwin_node *below;    /* Window below this one (or        */
  325.                 /* NIL if this is bottom window).   */
  326.                 /*                    */
  327.     BWINDOW         *pwin;    /* BWINDOW structure belonging        */
  328.                 /* to this node.            */
  329. } WIN_NODE;
  330.  
  331.  
  332.  
  333. /********************************************************************/
  334. /* Internal Data Types.                         */
  335. /********************************************************************/
  336.  
  337. typedef struct
  338. {
  339.     WN_ACTION        action;        /* The action to be taken.        */
  340.     KEY_SEQUENCE    key_sequence;   /* Key sequence to trigger it.  */
  341. } WN_KEY;
  342.  
  343.  
  344. typedef struct
  345. {
  346.     WN_ACTION        action;        /* The action to be taken.        */
  347.     MOUSE_EVENT     mouse;        /* Mouse event to trigger it.   */
  348. } WN_MOUSE;
  349.  
  350.  
  351. /********************************************************************/
  352. /* Internal Windows Macros.                        */
  353. /********************************************************************/
  354.  
  355.         /* Signature to identify genuine BWINDOW structure. */
  356. #define BWIN_SIGN   0xe928
  357. #define BWIN_DEAD     0
  358.  
  359.         /* Signature to identify genuine WIN_NODE structure.*/
  360. #define BNODE_SIGN  0xd928
  361. #define BNODE_DEAD     0
  362.  
  363.         /* Signature to identify genuine WN_EVENT_LIST        */
  364.         /* structure.                        */
  365. #define BEVENT_SIGN 0x65ab
  366. #define BEVENT_DEAD     0
  367.  
  368.                 /* Height of a REGION            */
  369. #define REGION_H(region) ((region).lr.row - (region).ul.row + 1)
  370.  
  371.                 /* Width of a REGION            */
  372. #define REGION_W(region) ((region).lr.col - (region).ul.col + 1)
  373.  
  374. #define BBRD_HASJOINTS      0x800
  375. #define BBRD_TYPE      0x01f
  376. #define BBRD_TITLE      0x7e0
  377.  
  378. #define B_WNPRBF_SIZE      1024
  379.  
  380. #define B_NATIVE_MAX_ROWS 25    /* Max rows supported by compiler's */
  381.                 /* native text windows.         */
  382.  
  383. #define wnreterr(errnum) return ((wnerror (errnum)), NIL)
  384. #define wnreterz(errnum) return ((wnerror (errnum)), 0)
  385. #define wnretern(errnum) return (wnerror (errnum))
  386.  
  387. #define wnreterv(errnum)                         \
  388.     {                                     \
  389.     wnerror (errnum);                         \
  390.     return;                              \
  391.     }
  392.  
  393. #define wnvalidn(pnode)                          \
  394.     {                                     \
  395.     if (wnvalnod (pnode) == NIL)                     \
  396.         wnreterr (WN_BAD_NODE);                     \
  397.     }
  398.  
  399. #define wnvalidw(pwin)                             \
  400.     {                                     \
  401.     if (wnvalwin (pwin) == NIL)                     \
  402.         wnreterr (WN_BAD_WIN);                     \
  403.     }
  404.  
  405. #define wnvalide(pevent)                         \
  406.     {                                     \
  407.     if (wnvalevn (pevent) == NIL)                     \
  408.         wnreterr (WN_BAD_EVENT);                     \
  409.     }
  410.  
  411. #define wnvalnod(pnode)  (wnvalno0((pnode),(BNODE_SIGN)))
  412.  
  413. #define wnvalwin(pwin)     (wnvalwi0((pwin),(BWIN_SIGN)))
  414.  
  415. #define wnvalevn(pevent) (wnvalev0((pevent),(BEVENT_SIGN)))
  416.  
  417.         /* Construct a new attribute from a given attribute */
  418.         /* and fore and back, either of which may be -1.    */
  419. #define wndoattr(attr, fore, back)                     \
  420.     utnybbyt ((back) == -1 ? uthinyb (attr) : (back),         \
  421.           (fore) == -1 ? utlonyb (attr) : (fore))
  422.  
  423.         /* Update a window's image.                         */
  424. #define wnputimg(pwin)                             \
  425.     wnnupblk((pwin), 0, 0, (wndata_h(pwin) - 1),             \
  426.           (wndata_w(pwin) - 1), WN_UPDATE)
  427.  
  428.         /* Macros to find a window's dimensions.            */
  429.  
  430.         /* Width & height of data area (no border).        */
  431. #define wndata_w(pwin)    ((pwin)->img.dim.w)
  432. #define wndata_h(pwin)    ((pwin)->img.dim.h)
  433.  
  434.         /* Width & height of window's border.               */
  435. #define wnbord_w(pwin)    ((pwin)->prev.dim.w)
  436. #define wnbord_h(pwin)    ((pwin)->prev.dim.h)
  437.  
  438.         /* Width & height of window's viewport (no border). */
  439. #define wnview_w(pwin)    ((pwin)->view_size.w)
  440. #define wnview_h(pwin)    ((pwin)->view_size.h)
  441.  
  442.  
  443. /********************************************************************/
  444. /* Error codes.                             */
  445. /********************************************************************/
  446.  
  447. #define WN_NO_ERROR        0
  448. #define WN_NO_MEMORY        1
  449. #define WN_ILL_DIM        2
  450. #define WN_NULL_PTR        3
  451. #define WN_BAD_WIN        4
  452. #define WN_BAD_DEV        5
  453. #define WN_BAD_PAGE        6
  454. #define WN_BAD_NODE        7
  455. #define WN_ALREADY_SHOWN    8
  456. #define WN_NOT_SHOWN        9
  457. #define WN_CANT_HIDE       10
  458. #define WN_COVERED       11
  459. #define WN_BAD_OPT       12
  460. #define WN_HARD        13
  461. #define WN_ILL_VALUE       14
  462. #define WN_PR_OVERFLOW       15
  463.  
  464. #define WN_NO_EVENT       30
  465. #define WN_EVENT_EXISTS    31
  466. #define WN_BAD_EVENT       32
  467. #define WN_NO_EXIT       33
  468.  
  469.  
  470.  
  471. /********************************************************************/
  472. /* Constants (type of borders and title(s)) for WNPUTBOR/WNDSPLAY.  */
  473. /********************************************************************/
  474.  
  475. #define BBRD_NO_BORDER 0x000
  476. #define BBRD_CHAR      0x01f
  477.  
  478.         /* The letters in the part after the underscore in  */
  479.         /* the following definitions are symbolic names for */
  480.         /* line styles.  A border style with double lines   */
  481.         /* on the top and left, and single lines on the     */
  482.         /* right and bottom would be BBRD_DSDS.  The order  */
  483.         /* of sides in the definition is clockwise from the */
  484.         /* top.                         */
  485. #define BBRD_SSSS      0x001
  486. #define BBRD_SSSD      0x002
  487. #define BBRD_DSSS      0x003
  488. #define BBRD_DSSD      0x004
  489. #define BBRD_SDSS      0x005
  490. #define BBRD_SDSD      0x006
  491. #define BBRD_DDSS      0x007
  492. #define BBRD_DDSD      0x008
  493. #define BBRD_SSDS      0x009
  494. #define BBRD_SSDD      0x00a
  495. #define BBRD_DSDS      0x00b
  496. #define BBRD_DSDD      0x00c
  497. #define BBRD_SDDS      0x00d
  498. #define BBRD_SDDD      0x00e
  499. #define BBRD_DDDS      0x00f
  500. #define BBRD_DDDD      0x010
  501.  
  502.         /* The letters in the part after the underscore in  */
  503.         /* the following definitions are symbolic names for */
  504.         /* title styles.  A title style with a top centered */
  505.         /* title would be BBRD_TCT; one with a bottom right */
  506.         /* title would be BBRD_BRT, and so on.            */
  507. #define BBRD_NO_TITLE  0x000
  508. #define BBRD_TLT       0x020
  509. #define BBRD_TCT       0x040
  510. #define BBRD_TRT       0x080
  511. #define BBRD_BLT       0x100
  512. #define BBRD_BCT       0x200
  513. #define BBRD_BRT       0x400
  514.  
  515.  
  516.  
  517. /********************************************************************/
  518. /* Constants (direction of scroll) for WNSCRBLK.            */
  519. /********************************************************************/
  520.  
  521. #define WNSCR_UP    0
  522. #define WNSCR_DOWN  1
  523. #define WNSCR_RIGHT 2
  524. #define WNSCR_LEFT  3
  525.  
  526.  
  527.  
  528. /********************************************************************/
  529. /* Constants (option OR values) for WNWRSTRN.                */
  530. /********************************************************************/
  531.  
  532. #define WN_NO_UPDATE  0x04
  533. #define WN_UPDATE     0x00
  534. #define WN_LF_LF      0x08
  535. #define WN_LF_CRLF    0x00
  536. #define WN_NO_SCROLL  0x10
  537. #define WN_SCROLL     0x00
  538. #define WN_NO_TRACK   0x20
  539. #define WN_CHAR_TRACK 0x00
  540.  
  541.  
  542.  
  543. /********************************************************************/
  544. /* Window control items & status items for WNGETOPT & WNSETOPT.     */
  545. /* Negative item codes require the window to be currently        */
  546. /* displayed (although it may be hidden).                */
  547. /********************************************************************/
  548.  
  549. #define WN_DEVICE         1    /* Where the window is            */
  550. #define WN_PAGE        (-2) /* displayed                */
  551. #define WN_ROW_CORNER       (-3) /*                    */
  552. #define WN_COL_CORNER       (-4) /*                    */
  553.                 /*                    */
  554. #define WN_HIDDEN       (-5) /* Whether it's hidden.             */
  555.                 /*                    */
  556. #define WN_CUR_OFF         6    /* Cursor on/off state            */
  557. #define WN_CUR_HIGH         7    /* Cursor scan lines            */
  558. #define WN_CUR_LOW         8    /*                    */
  559.  
  560.                 /* User-controllable options        */
  561. #define WN_DELAYED         9    /*                    */
  562. #define WN_REMOVABLE        10    /*                    */
  563.  
  564. #define WN_FROZEN        11    /* Internal effects of            */
  565. #define WN_DIRTY        12    /*   displaying windows         */
  566. #define WN_ANY_DATA_COVERED 13    /*                    */
  567.  
  568. #define WN_ROWS         14    /* Dimensions of data area        */
  569. #define WN_COLS         15    /*                    */
  570.                 /*                    */
  571. #define WN_ROW_REL        16    /* Cursor location relative to        */
  572. #define WN_COL_REL        17    /* data area                */
  573.                 /*                    */
  574. #define WN_ROW_ABS      (-18) /* Absolute cursor location on        */
  575. #define WN_COL_ABS      (-19) /* screen                */
  576.  
  577. #define WN_ROW_OVERALL      (-27) /* Location of window with        */
  578. #define WN_COL_OVERALL      (-28) /* border.                */
  579. #define WN_HT_OVERALL      (-29) /* Dimensions of window with        */
  580. #define WN_WID_OVERALL      (-30) /* existing border.            */
  581.                 /*                    */
  582. #define WN_ATTR         20    /* Default attributes for data        */
  583.                 /* area                 */
  584.                 /*                    */
  585. #define WN_BOR_TYPE        22    /* Border type                */
  586. #define WN_BOR_CHAR        23    /* Border character            */
  587. #define WN_BOR_ATTR        24    /* Border attribute            */
  588. #define WN_BOR_TTATTR        32    /* Border top title attribute        */
  589. #define WN_BOR_BTATTR        33    /* Border bottom title attribute    */
  590.                 /*                    */
  591. #define WN_IS_CURRENT        25    /* Whether this is the current        */
  592.                 /* window                */
  593.                 /*                    */
  594. #define WN_ACTIVE_CUR      (-26) /* Whether this window (among        */
  595.                 /* all the windows displayed on     */
  596.                 /* its page) is the one whose        */
  597.                 /* cursor is active.            */
  598.                 /*                    */
  599. #define WN_PREV_ALLOC        31    /* Whether space has been allocated */
  600.                 /* for the text underneath this     */
  601.                 /* window (when displayed and not   */
  602.                 /* hidden).                */
  603.                 /*                    */
  604. #define WN_CUR_TRACK        34    /* Whether the window's data area   */
  605.                 /* will always be positioned so     */
  606.                 /* so that the cursor is visible in */
  607.                 /* the viewport.            */
  608.                 /*                    */
  609. #define WN_CUR_L_MARG        35    /* The number of columns to leave   */
  610. #define WN_CUR_R_MARG        36    /* as a margin on the left and        */
  611.                 /* right when performing cursor     */
  612.                 /* auto tracking.            */
  613.                 /*                    */
  614. #define WN_CUR_T_MARG        37    /* The number of rows to leave as a */
  615. #define WN_CUR_B_MARG        38    /* margin on the top and bottom     */
  616.                 /* when performing cursor auto        */
  617.                 /* tracking.                */
  618.                 /*                    */
  619. #define WN_HT_VIEW      (-39) /* The height and width of the        */
  620. #define WN_WID_VIEW      (-40) /* window's viewport.               */
  621.                 /*                    */
  622.  
  623.  
  624.  
  625. /********************************************************************/
  626. /* Constants (option OR values) for WNSCRLBR.                */
  627. /********************************************************************/
  628.  
  629. #define WN_HORIZONTAL 0x01
  630. #define WN_VERTICAL   0x02
  631.  
  632.  
  633.  
  634. /********************************************************************/
  635. /* Constants (option OR values) for WNREAD and WNPOLL.            */
  636. /********************************************************************/
  637.  
  638. #define WN_KNOWN_EVENTS     0x00
  639. #define WN_UNKNOWN_TRANSMIT 0x01
  640. #define WN_ALL_TRANSMIT     0x03
  641. #define WN_KBIGNORE        0x04
  642.  
  643. #define WN_USE_MOUSE        0x00
  644. #define WN_NO_MOUSE        0x08
  645.  
  646.  
  647.  
  648. /********************************************************************/
  649. /* User Macros.                             */
  650. /********************************************************************/
  651.  
  652. #define wncreate(height,width,attr)                     \
  653.     (wncreat0((height),(width),(attr),(BWIN_SIGN),(BNODE_SIGN)))
  654.  
  655. #define wndsplay(pwin, pwhere, pbord)                     \
  656.     (wnvdisp((pwin),(pwhere),wndata_h((pwin)),wndata_w((pwin)),  \
  657.           0,0,(pbord)))
  658.  
  659.         /* Write a character to the current window        */
  660.         /* TTY-style.                        */
  661. #define wnwrtty(ch, fore, back)                      \
  662.     (wnwrttyx (b_pcurwin, (ch), (fore), (back),             \
  663.            WN_UPDATE | WN_LF_LF))
  664.  
  665.         /* Write a string to the current window TTY-style   */
  666.         /* with scrolling and end-of-line character wrap.   */
  667. #define wnwrstr(pbuffer, fore, back)                     \
  668.     (wnwrstrn (b_pcurwin, (pbuffer), 0, (fore), (back),         \
  669.            WN_UPDATE | CHARS_ONLY))
  670.  
  671.         /* Change attributes on current window (but don't   */
  672.         /* change default).                    */
  673. #define wnattr(fore, back)                         \
  674.     (wnatrblk(b_pcurwin, 0, 0, (wndata_h(b_pcurwin) - 1),         \
  675.           (wndata_w(b_pcurwin) - 1), (fore), (back),         \
  676.           WN_UPDATE))
  677.  
  678.         /* Set up and allow user input in a window oriented */
  679.         /* edit field.                        */
  680. #define wnfield(pwin,pinitstr,pretstr,target_size,pfield_control,pfinal) \
  681.     (edbase((pwin), (pinitstr), (pretstr), (target_size),        \
  682.            (pfield_control), (pfinal), (PED_RET_FUNC) wnretinf, \
  683.            (PED_SET_FUNC) wnsetcur, (PED_WRITE_FUNC) wnwrrect))
  684.  
  685.  
  686. /********************************************************************/
  687. /* Global variables                            */
  688. /********************************************************************/
  689.  
  690. extern int    b_wnerr;    /* Most recent error            */
  691.                 /* (WN_NO_ERROR if none).        */
  692.  
  693. extern BWINDOW *b_pcurwin;    /* Window selected for I/O        */
  694.                 /* (NIL if none).            */
  695.  
  696. extern long    b_win_hold;    /* Amount of time to wait before    */
  697.                 /* reporting MO_HOLD events.        */
  698.  
  699. extern unsigned b_win_delay;    /* Amount of time to wait between   */
  700.                 /* successive window polls.        */
  701.  
  702. extern WN_KEY    b_winkeys[];    /* Array of default window key        */
  703.                 /* assignments.             */
  704.  
  705. extern WN_MOUSE b_winmouse[];    /* Array of default window mouse    */
  706.                 /* assignments.             */
  707.  
  708.  
  709. /********************************************************************/
  710. /* Global variables for internal use only                */
  711. /********************************************************************/
  712.  
  713. extern char    *b_wnprbf;    /* Buffer allocated for WNPRINTF.   */
  714.  
  715. extern unsigned int b_wnbfsz;    /* Size of buffer allocated for     */
  716.                 /* WNPRINTF.                */
  717.  
  718.                 /* List of windows displayed on     */
  719.                 /* each page (NIL if none).        */
  720. extern WIN_NODE *(b_wnlist[MAX_DEVICES][MAX_PAGES]);
  721.  
  722.                 /* The window (on each page)        */
  723.                 /* selected to have a visible        */
  724.                 /* cursor (NIL if none).        */
  725. extern WIN_NODE *(b_pactnode[MAX_DEVICES][MAX_PAGES]);
  726.  
  727.  
  728.  
  729.  
  730. /********************************************************************/
  731. /* User function declarations by category.                */
  732. /********************************************************************/
  733.         /* Window destruction.                    */
  734.  
  735. int cdecl wndstroy (BWINDOW *); /* Detach from screen & discard     */
  736.                 /* memory structures (does not        */
  737.                 /* alter screen).            */
  738.  
  739.  
  740.         /* Controlling/retrieving window options & status.  */
  741.  
  742. BWINDOW *cdecl wnsetopt (    /* Set option.                */
  743.          BWINDOW *,    /*                    */
  744.          int, int);    /*                    */
  745.                 /*                    */
  746. BWINDOW *cdecl wngetopt (    /* Retrieve option or status.        */
  747.          BWINDOW *,    /*                    */
  748.          int,int *);    /*                    */
  749.  
  750.  
  751.         /* Error reporting.                    */
  752.  
  753. #if WN_EXT_ERROR        /*                    */
  754.                 /* External version:            */
  755. int cdecl wnerror(int);     /* Set or clear error code and        */
  756.                 /* return it.                */
  757. #else                /* Macro version:            */
  758. #define wnerror(ercode) \    /*                    */
  759.       (b_wnerr = (ercode))    /*                    */
  760. #endif                /*                    */
  761.  
  762.  
  763.          /* Displaying/removing  windows.            */
  764.  
  765. BWINDOW *cdecl wnremove (    /* Remove window from display page. */
  766.          BWINDOW *);    /*                    */
  767.                 /*                    */
  768. BWINDOW *cdecl wnupdate (    /* Satisfy pending output requests. */
  769.          BWINDOW *);    /*                    */
  770.                 /*                    */
  771. BWINDOW *cdecl wnrevupd (void); /* Read image of current window     */
  772.                 /* from the screen.            */
  773.                 /*                    */
  774. int     cdecl wnredraw (int,    /* Redisplay all windows on a        */
  775.          int);        /* display page and restore cursor. */
  776.  
  777.  
  778.         /* Cursor action.                    */
  779.  
  780. BWINDOW *cdecl wncursor (    /* Select for visible cursor        */
  781.          BWINDOW *);    /* (deselect other windows shown    */
  782.                 /* on this display page.)        */
  783.                 /*                    */
  784. BWINDOW *cdecl wncurmov (int,    /* Move current window's cursor     */
  785.          int);        /* relative to the window's data    */
  786.                 /* area.                */
  787.                 /*                    */
  788. BWINDOW *cdecl wncurpos (int *, /* Return current window's cursor   */
  789.          int *);    /* position relative to the        */
  790.                 /* window's data area.              */
  791.  
  792.  
  793.         /* Miscellaneous.                    */
  794.  
  795. BWINDOW *cdecl wnselect (    /* Select window for I/O (deselect  */
  796.          BWINDOW *);    /* all other windows) making this   */
  797.                 /* the "current" window.            */
  798.                 /*                    */
  799. unsigned cdecl wnsetbuf (    /* Make scratch buffer for WNPRINTF.*/
  800.          unsigned);    /*                    */
  801.                 /*                    */
  802. BWINDOW *cdecl wnscrlbr (    /* Make scrollbar sensors.        */
  803.          BWINDOW *, int,/*                    */
  804.          int, unsigned, /*                    */
  805.          int);        /*                    */
  806. void     cdecl wnzapsen(    /* Zap a window's sensor list.      */
  807.          BWINDOW *);    /*                    */
  808.  
  809.         /* Window output.                    */
  810.  
  811. void     cdecl wnwrap (int,    /* Write a string TTY-style with    */
  812.        const char *, int,    /* word wrap.                */
  813.          int, int);    /*                    */
  814.                 /*                    */
  815. void     cdecl wnwrstrn (    /* Write a string of a given length */
  816.          BWINDOW *,    /* TTY-style with end-of-line        */
  817.        const char *, int,    /* character wrap.            */
  818.          int, int, int);/*                    */
  819.                 /*                    */
  820. int     cdecl wnwrbuf (int,    /* Write a buffer to a given        */
  821.          int, int,    /* location in the current window's */
  822.        const char *, int,    /* data area.                */
  823.          int, int);    /*                    */
  824.                 /*                    */
  825. int     cdecl wnprintf (    /* Do a PRINTF to the current        */
  826.        const char *, ...);    /* window.                */
  827.                 /*                    */
  828. BWINDOW *cdecl wnwrrect (    /* Write to a rectangular region of */
  829.          BWINDOW *, int,/* a window.                */
  830.          int, int, int, /*                    */
  831.          const char *,    /*                    */
  832.          int, int, int);/*                    */
  833.                 /*                    */
  834.  
  835.  
  836.         /* Window input.                    */
  837.  
  838. int     cdecl wnrdbuf (int,    /* Read part of the current        */
  839.          int, int,    /* window's data area into a        */
  840.          char *, int);    /* buffer.                */
  841.                 /*                    */
  842. char     cdecl wnquery (char *, /* Return input from operator.        */
  843.          int,int *);    /*                    */
  844.                 /*                    */
  845. WN_EVENT *cdecl wnread (    /* Display a window and accept user */
  846.           BWINDOW *,    /* responses.                */
  847.           const WHERE *,/*                    */
  848.           int, int,    /*                    */
  849.           int, int,    /*                    */
  850.           const     /*                    */
  851.             BORDER *,    /*                    */
  852.           WN_EVENT *,    /*                    */
  853.           int);     /*                    */
  854.                 /*                    */
  855. WN_EVENT *cdecl wnpoll(     /* Poll the mouse/keyboard once for */
  856.         WN_EVENT_LIST *,/* a user response belonging to a   */
  857.         unsigned *,    /* specified set of events.        */
  858.         unsigned *,    /*                    */
  859.         WN_EVENT *);    /*                    */
  860.                 /*                    */
  861. int     cdecl wninitev (    /* Initialize window event list.    */
  862.          BWINDOW *);    /*                    */
  863.                 /*                    */
  864. int     cdecl wnchgevn (    /* Change a window event in the     */
  865.            WN_EVENT_LIST **,/* specified event list.        */
  866.            WN_EVENT *,    /*                    */
  867.            WN_ACTION);    /*                    */
  868.                 /*                    */
  869. int     cdecl wnremevn(    /* Delete a window event in the     */
  870.            WN_EVENT_LIST **,/* specified event list.        */
  871.            const        /*                    */
  872.          WN_EVENT *);    /*                    */
  873.                 /*                    */
  874. void     cdecl wnzapevn(    /* Release the entire event list    */
  875.           WN_EVENT_LIST **);/* specified.           .        */
  876.                 /*                    */
  877.  
  878.  
  879.         /* Window scrolling.                    */
  880.  
  881. BWINDOW *cdecl wnscrblk (    /* Scroll a block-section of a        */
  882.          BWINDOW *,    /* window a specified number of     */
  883.          int, int, int, /* rows/columns.            */
  884.          int, int, int, /*                    */
  885.          int, int, int);/*                    */
  886.                 /*                    */
  887. BWINDOW *cdecl wnscroll (    /* Vertically scroll current window.*/
  888.          int, int,    /*                    */
  889.          int, int);    /*                    */
  890.                 /*                    */
  891. BWINDOW *cdecl wnhoriz (    /* Horizontally scroll current        */
  892.          int, int,    /* window.                */
  893.          int, int);    /*                    */
  894.                 /*                    */
  895.  
  896.  
  897.         /* Attribute manipulation.                */
  898.  
  899. BWINDOW *cdecl wnatrblk (    /* Change attributes on a block-    */
  900.          BWINDOW *,    /* section of a window.         */
  901.          int, int, int, /*                    */
  902.          int, int, int, /*                    */
  903.          int);        /*                    */
  904.                 /*                    */
  905. BWINDOW *cdecl wnatrstr (    /* Change attributes on a stream-   */
  906.          BWINDOW *,    /* section of a window.         */
  907.          int, int, int, /*                    */
  908.          int, int,    /*                    */
  909.          int);        /*                    */
  910.                 /*                    */
  911.  
  912.         /* Virtual windows.                    */
  913.  
  914. BWINDOW *cdecl wnvdisp (    /* Display virtual window with        */
  915.          BWINDOW *,    /* border.                */
  916.          const WHERE *, /*                    */
  917.          int, int,    /*                    */
  918.          int, int,    /*                    */
  919.          const        /*                    */
  920.              BORDER *); /*                    */
  921.                 /*                    */
  922. BWINDOW *cdecl wnorigin (    /* Set the coordinates of the data  */
  923.          BWINDOW *, int,/* area which will appear in the    */
  924.          int, int);    /* viewport's origin.               */
  925.                 /*                    */
  926. BWINDOW *cdecl wnshoblk (    /* Shift the window's data area to  */
  927.          BWINDOW *,    /* show a specified block.        */
  928.          const REGION *,/*                    */
  929.          const LOC *,    /*                    */
  930.          const LOC *,    /*                    */
  931.          int);        /*                    */
  932.                 /*                    */
  933.  
  934.  
  935.  
  936. /********************************************************************/
  937. /* Internal functions by category                    */
  938. /********************************************************************/
  939.  
  940.         /* Window creation.                    */
  941.  
  942. BWINDOW *cdecl wncreat0(int,int,int,unsigned,unsigned);
  943.  
  944.  
  945.         /* Device & page switching.                */
  946.  
  947. int cdecl wnseldev(const WHERE *,const DIM *,int *);
  948.  
  949.  
  950.         /* Error detection.                    */
  951.  
  952. BWINDOW       *cdecl wnvalwi0(BWINDOW *,unsigned);
  953. WIN_NODE      *cdecl wnvalno0(WIN_NODE *,unsigned);
  954. WN_EVENT_LIST *cdecl wnvalev0(WN_EVENT_LIST *,unsigned);
  955.  
  956.  
  957.         /* Restoring previous screen contents.            */
  958.  
  959. BWINDOW *cdecl wnresprv(BWINDOW *);
  960.  
  961.  
  962.         /* Handling IMAGE structures.                */
  963.  
  964. BWINDOW *cdecl wnpimblk(BWINDOW *,int,int,int,int);
  965. IMAGE    *cdecl wngetimg(IMAGE *,const WHERE *);
  966.  
  967.  
  968.         /* Manipulating chains of WIN_NODEs.            */
  969.  
  970. WIN_NODE *cdecl wnpgadd(BWINDOW *,int,int);
  971. BWINDOW  *cdecl wnpgrem(BWINDOW *);
  972.  
  973.  
  974.         /* Building borders.                    */
  975.  
  976. int cdecl wnputbor(const DIM *,const BORDER *,const WHERE *);
  977.  
  978.  
  979.         /* Building sensor lists.                */
  980.  
  981. int cdecl wnputsen(BWINDOW *);
  982.  
  983.         /* Handling window events.                */
  984.  
  985. WN_EVENT *cdecl wnretevn(WN_EVENT_LIST *, const WN_EVENT *);
  986.  
  987.         /* Handling inter-window effects:  displaying,        */
  988.         /* overlapping, removing.                */
  989.  
  990. BWINDOW *cdecl wnneedup(BWINDOW *);
  991. BWINDOW *cdecl wnnupblk(BWINDOW *,int,int,int,int,int);
  992. WIN_NODE *cdecl wncover(WIN_NODE *,const LOC *,const DIM *);
  993. int cdecl wnovrlap(const LOC *,const DIM *,const LOC *,const DIM *);
  994. BWINDOW *cdecl wnforget(BWINDOW *);
  995. BWINDOW *cdecl wnhide(BWINDOW *);
  996. BWINDOW *cdecl wnunhide(BWINDOW *);
  997.  
  998.  
  999.         /* Window output.                    */
  1000.  
  1001. void cdecl wnwrttyx(BWINDOW *,char,int,int,int);
  1002.  
  1003.  
  1004.         /* Cursor handling.                    */
  1005.  
  1006. BWINDOW *cdecl wncurtrk(BWINDOW *, int, int);
  1007. void cdecl     wncurset(BWINDOW *);
  1008.  
  1009.  
  1010.         /* Native text window handling.             */
  1011.  
  1012. void cdecl wncmove(BWINDOW *, int, int);
  1013. void cdecl wnsetwin(int,int,int,int);
  1014. int  cdecl wnchkdm(BWINDOW *);
  1015. void cdecl wngetatr(BWINDOW *);
  1016. void cdecl wnsetatr(int);
  1017.  
  1018.         /* Window edit fields.                    */
  1019.  
  1020. int  cdecl wnretinf(BWINDOW *, CUR_INFO *, const LOC *, int, int);
  1021. int  cdecl wnsetcur(BWINDOW *, int, CUR_TYPE *, int, int);
  1022.  
  1023.  
  1024. #endif                /* Ends "#ifndef DEF_BWINDOW"       */
  1025.